package com.laurent.brewerhistory.fragments;

import com.laurent.brewerhistory.MainActivity;
import com.laurent.brewerhistory.R;

import android.app.Fragment;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class MenuFragment extends ListFragment {

	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.sliding_menu, null);
	}

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {

		Fragment f = null;

		switch (position) {
		case 0:
			// En cours
			f = new CurrentBeerFragment();
			break;
		case 1:
			// Historique
			f = new HistoryFragment();
			break;
		case 2:
			// Préférences
			f = new PreferencesFragment();
			break;
		default:
			super.onListItemClick(l, v, position, id);
			break;
		}

		if (f != null) {
			if (getActivity() instanceof MainActivity) {
				MainActivity a = (MainActivity) getActivity();
				a.switchContent(f);
			}
		}
	}
}
